home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Alles Voor Internet / Tout Pour Internet
/
alles voor internet.iso
/
MacInternet™
/
Telnet
/
NCSA
/
tn3270 2.3d26 source
/
tn3270 tools
/
genattn.c
next >
Wrap
C/C++ Source or Header
|
1991-01-21
|
8KB
|
349 lines
/*
* tn3270 for the Macintosh Source Code
* Brown University Computing and Information Services
* Version 2.3d21, January 17, 1991
* Copyright (c) 1988, 1989, 1990, 1991 by Brown University and by
* Peter John DiCamillo.
*
* Permission is granted to any individual or institution to use, copy,
* or redistribute the binary version of this software and its
* documentation provided this notice and the copyright notices are
* retained. Permission is granted to any individual or non-profit
* institution to use, copy, modify, or redistribute the source files
* of this software provided this notice and the copyright notices are
* retained. This software may not be distributed for profit, either
* in original form or in derivative works, nor can the source be
* distributed to other than an individual or a non-profit institution.
* Any individual or group interested in seeing and/or using these
* source files but who are prevented from doing so by the above
* constraints should contact Don Wolfe, Assistant Vice-President for
* Computer Systems at Brown University, (401) 863-7250, for possible
* software licensing of the source developed at Brown.
*
* Brown University and Peter John DiCamillo make no representations
* about the suitability of this software for any purpose.
*
* BROWN UNIVERSITY AND PETER JOHN DICAMILLO GIVE NO WARRANTY, EITHER
* EXPRESS OR IMPLIED, FOR THE PROGRAM AND/OR DOCUMENTATION PROVIDED,
* INCLUDING, WITHOUT LIMITATION, WARRANTY OF MERCHANTABILITY AND
* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE.
*
*/
#define fileMenu 256
#include <Quickdraw.h>
#include <Fonts.h>
#include <Windows.h>
#include <Menus.h>
#include <Dialogs.h>
#include <Memory.h>
#include <SegLoad.h>
#include <Events.h>
#include <Desk.h>
#include <fcntl.h>
char done; /* flag for mainline to return */
struct Rect screenRect, dragRect, pRect, sizeRect;
struct WindowRecord wRecord;
struct GrafPort *myWindow;
MenuHandle myMenus[1];
char * name1[32] =
{"PF1", "PF2", "PF3", "PF4", "PF5", "PF6",
"PF7", "PF8", "PF9", "PF10", "PF11", "PF12",
"PF13", "PF14", "PF15", "PF16", "PF17",
"PF18", "PF19", "PF20", "PF21", "PF22",
"PF23", "PF24", "Sys", "Clear", "PA1",
"PA2", "Erase", "Insert", "Delete", "Insert"};
char * name2[32] =
{"", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "",
"Req", "", "", "", "EOF", "Mode",
"Char", "Char"};
main()
{
short rc;
macinit(); /* general Mac initialization */
defattn(0);
done = 0;
while (!done) hndmac();
}
macinit()
{
/* set-up general Macintosh environment */
InitGraf(&qd.thePort);
InitWindows();
InitFonts();
InitMenus();
InitDialogs(0L);
InitCursor();
myMenus[0] = NewMenu(fileMenu, "File");
AppendMenu(myMenus[0], "Save");
AppendMenu(myMenus[0], "Quit");
InsertMenu(myMenus[0], 0);
DrawMenuBar();
screenRect = qd.screenBits.bounds;
SetRect(&dragRect, 4, 24, screenRect.right-4, screenRect.bottom-4);
pRect.top = 23;
pRect.left = 5;
pRect.bottom = 337;
pRect.right = 505;
sizeRect.top = 25;
sizeRect.left = 25;
sizeRect.bottom = 296;
sizeRect.right = 501;
myWindow = NewWindow(&wRecord, &pRect, "genattn",
true, 3, -1L, 0, 0L);
SetPort(myWindow);
pRect = qd.thePort->portRect;
}
hndmac()
{
register short code;
register unsigned short i, w, h;
register long l;
GrafPtr gp;
long pt;
struct EventRecord myEvent;
struct GrafPort *whichWindow;
/* handle system events */
SystemTask();
if (!GetNextEvent(everyEvent, &myEvent)) return;
switch(myEvent.what) {
case mouseDown:
code = FindWindow(&myEvent.where, &whichWindow);
switch (code) {
case inMenuBar:
docommand(MenuSelect(&myEvent.where));
break;
case inSysWindow:
SystemClick(&myEvent, whichWindow);
break;
case inDrag:
DragWindow(whichWindow, &myEvent.where, &dragRect);
break;
case inGrow:
if (whichWindow == FrontWindow()) {
l = GrowWindow(whichWindow, &myEvent.where,
&sizeRect);
h = l >> 16;
w = l & 0x0000ffffL;
SizeWindow(whichWindow, w, h, true);
}
break;
case inContent:
if (whichWindow != FrontWindow()) {
SelectWindow(whichWindow);
}
break;
}
break;
case mouseUp:
break;
case keyDown:
case autoKey:
break;
case activateEvt:
break;
case updateEvt:
BeginUpdate((WindowPtr)myEvent.message);
EndUpdate((WindowPtr)myEvent.message);
break;
default: break;
}
}
docommand(mResult)
long mResult;
{
register short theItem, theMenu;
register char name[40];
theMenu = mResult >> 16;
theItem = mResult;
switch(theMenu) {
case fileMenu:
switch (theItem) {
case 1: defattn(1);
done = 1;
break;
case 2: done = 1;
break;
default:
break;
}
break;
default:
break;
}
HiliteMenu(0);
}
defattn(save)
char save;
{
Rect mr;
Rect keyrect;
Rect framerect;
register short i, j;
short fd, keynum;
char hexline[120];
BitMap menumap;
GrafPtr currport;
unsigned char * bitptr;
mr.top = 40;
mr.left = 66;
mr.bottom = mr.top + 101;
mr.right = mr.left + 343;
/* entire menu (done by menu manager) */
framerect.top = mr.top - 1;
framerect.left = mr.left - 1;
framerect.bottom = mr.bottom + 1;
framerect.right = mr.right + 1;
FrameRect(&framerect);
/* pf1-12 */
framerect.top = mr.top + 1;
framerect.left = mr.left + 1;
framerect.bottom = mr.bottom - 1;
framerect.right = mr.left + 127;
FrameRect(&framerect);
keynum = 0;
keyrect.top = mr.top + 3;
keyrect.bottom = keyrect.top + 23;
for (i = 0; i < 4; i++) {
keyrect.left = mr.left + 3;
keyrect.right = keyrect.left + 40;
for (j=0; j < 3; j++) {
FrameRect(&keyrect);
addtext(&keyrect, name1[keynum], name2[keynum]);
keynum++;
keyrect.left += 41;
keyrect.right += 41;
}
keyrect.top += 24;
keyrect.bottom += 24;
}
/* pf13-24 */
framerect.top = mr.top + 1;
framerect.left = mr.left + 216;
framerect.bottom = mr.bottom - 1;
framerect.right = mr.left + 342;
FrameRect(&framerect);
keyrect.top = mr.top + 3;
keyrect.bottom = keyrect.top + 23;
for (i = 0; i < 4; i++) {
keyrect.left = mr.left + 218;
keyrect.right = keyrect.left + 40;
for (j=0; j < 3; j++) {
FrameRect(&keyrect);
addtext(&keyrect, name1[keynum], name2[keynum]);
keynum++;
keyrect.left += 41;
keyrect.right += 41;
}
keyrect.top += 24;
keyrect.bottom += 24;
}
/* special keys */
framerect.top = mr.top + 1;
framerect.left = mr.left + 129;
framerect.bottom = mr.bottom - 1;
framerect.right = mr.left + 214;
FrameRect(&framerect);
keyrect.top = mr.top + 3;
keyrect.bottom = keyrect.top + 23;
for (i = 0; i < 4; i++) {
keyrect.left = mr.left + 131;
keyrect.right = keyrect.left + 40;
for (j=0; j < 2; j++) {
FrameRect(&keyrect);
addtext(&keyrect, name1[keynum], name2[keynum]);
keynum++;
keyrect.left += 41;
keyrect.right += 41;
}
keyrect.top += 24;
keyrect.bottom += 24;
}
if (save == 0) return;
bitptr = (unsigned char *)NewPtr(4448L);
menumap.baseAddr = (Ptr)bitptr;
for (i=0; i < 4448; i++) *(bitptr + i) = 0;
menumap.rowBytes = 44;
menumap.bounds.top = 0;
menumap.bounds.left = 0;
menumap.bounds.bottom = mr.bottom - mr.top;
menumap.bounds.right = mr.right - mr.left;
GetPort(&currport);
CopyBits(&(currport->portBits), &menumap, &mr, &(menumap.bounds),
srcCopy, 0L);
fd = open("hd:mpw:tn3270:attnmap.hex", O_CREAT+O_WRONLY);
for (i=0; i < 4448; i+= 8) {
sprintf(hexline, "%02x%02x %02x%02x %02x%02x %02x%02x\n",
*(bitptr+i), *(bitptr+i+1),
*(bitptr+i+2), *(bitptr+i+3),
*(bitptr+i+4), *(bitptr+i+5),
*(bitptr+i+6), *(bitptr+i+7));
write(fd, hexline, strlen(hexline));
}
close(fd);
DisposPtr(bitptr);
}
addtext(key, name1, name2)
Rect * key;
char * name1;
char * name2;
{
short w;
TextFont(3);
if (name2[0] == 0) {
TextSize(12);
w = StringWidth(name1);
if (w > 38) w = 38;
w = (38-w)/2;
MoveTo((*key).left+w+1, (*key).bottom-7);
DrawString(name1);
}
else {
TextSize(9);
w = StringWidth(name1);
if (w > 38) w = 38;
w = (38-w)/2;
MoveTo((*key).left+w+1, (*key).bottom-13);
DrawString(name1);
w = StringWidth(name2);
if (w > 38) w = 38;
w = (38-w)/2;
MoveTo((*key).left+w+1, (*key).bottom-4);
DrawString(name2);
}
}